package com.qcby.lxt.framedemo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qcby.lxt.framedemo.entity.Test;
import com.qcby.lxt.framedemo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @className: Demo
 * @description:
 * @author: lxt
 * @create: 2021-04-17 23:33
 **/

@RequestMapping
@Controller
public class Demo {
    @Autowired
    private TestService testService;

    @GetMapping("hello")
    @ResponseBody
    public String hello(){
        return "hello world";
    }

    @GetMapping("hello1")
    public String hello1(){
        return "hello1";
    }

    @GetMapping("hello2")
    @ResponseBody
    public List<Test> hello2(int pageNo,int pageSize){
        return testService.list(pageNo,pageSize);
    }

    /**
     * 查询所有数据
     * @return
     */
    @GetMapping("hello3")
    @ResponseBody
    public List<Test> hello3(){
        return testService.list();
    }
    /**
     * 分页查询
     * @return
     */
    @GetMapping("hello4")
    @ResponseBody
    public IPage<Test> hello4(int pageNo, int pageSize){
        IPage<Test> page = new Page<>(pageNo,pageSize);
        return testService.page(page);
    }
}
